<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="org.json.simple.JSONObject"%>
<%@ page import="org.json.simple.JSONArray"%>
<%@ page import="java.net.URLEncoder"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
	String memail1 = request.getParameter("memail1");
	//String memail1 = "csj@gmail.com";

	String url = "jdbc:oracle:thin:@192.168.0.18:1521:orcl";
	String user = "book";
	String password = "book";
	String sql = null;
	String respassword = null;
	String resmeail1 = null;

	Connection conn = null;
	ResultSet rs = null;
	PreparedStatement stmt=null;

	JSONObject jsonMain = new JSONObject();
	JSONObject obj = new JSONObject();

	JSONArray arr = new JSONArray();

	try {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		//out.println("드라이버 로딩 성공");
		conn = DriverManager.getConnection(url, user, password);
		//out.println("접속 성공");
		sql = "SELECT MPASSWORD,MEMAIL1 FROM MEMBER WHERE MEMAIL1=?";
		stmt = conn.prepareStatement(sql);

		stmt.setString(1, memail1);
		rs = stmt.executeQuery();

		while (rs.next()) {

			respassword = rs.getString("mpassword");
			resmeail1 = rs.getString("memail1");
		}

		if (resmeail1 == null) {
			obj.put("res", "no");
			arr.add(obj);

		} else {
			obj.put("mpassword",respassword);
			//arr.add(obj1);
			obj.put("res", "ok");
			arr.add(obj);
		}

		jsonMain.put("mpassword", arr);
		out.println(jsonMain);

	} catch (Exception e) {

		e.printStackTrace();
	}finally{
		if(stmt!=null) stmt.close();
		if(conn!=null) conn.close();
	}
%>
